
<%@ page import="controllers.CommonConnect" %>
<%@ page import="controllers.SolutionConnect" %>
<%@ page import="controllers.CustomerConnect" %>
<%@ page import="controllers.AreaConnect" %>
<%@ page import="models.SolutionSubmission" %>
<%@ page import="controllers.SiteConnect" %>
<%@ page import="java.util.List,java.text.*"%>
<%@ page import="com.googlecode.objectify.Objectify" %>
<%@ page import="com.googlecode.objectify.ObjectifyService" %>
<%@ page import="com.googlecode.objectify.Query" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.text.*,java.util.*"%>


<%

 
//String UserEmail = (String) pageContext.getAttribute("USER_EMAILID");


//int i =0;
long awd_id = 0;
String optionName ="";
//SimpleDateFormat dt = new SimpleDateFormat("MM/dd/yyyy");
//SimpleDateFormat dt1 = new SimpleDateFormat("MM/dd/yyyy");
Date today = new java.util.Date();
//String DisplayDate =  dt1.format(today);
long optionValue =0;
String user_email1 = (String) pageContext.getAttribute("USER_EMAILID", PageContext.PAGE_SCOPE);

//Comment by Kulprapas OCT 18,2012
//CustomerConnect Cust = new  CustomerConnect(); 
//List<HashMap<String,Object>> Crs = Cust.getCompleteData();
//Revise the code to order Customer list by kulprapas OCT 18, 2012
CommonConnect Cust = new  CommonConnect(); 
List<HashMap<String,Object>> Crs = Cust.getCustomer();



CommonConnect Process = new  CommonConnect(); 
List<HashMap<String,Object>> Prs = Process.GetArea();   

CommonConnect Location  = new  CommonConnect(); 
List<HashMap<String,Object>> Lrs = Location.GetLocation(); 

	boolean qfound = false;
	boolean bCustomer = false;
	boolean bLocation = false;
	boolean bProcessarea = false;
	boolean bSolType = false;
	boolean bFinBenfit = false;
	boolean bBenefit = false;
	boolean bAchBenfit = false;
	boolean bfromDt = false;
	boolean btoDt = false;
	long solID;
	String solTitle = "";
	String solCustomer = "";
	String solLocation = "";
	String solProcessArea = "";
	String fromDt1 ="";
	String toDt1 ="";
	String AchievedValue = "";
	String AchievedUnit = "";
	String BenefitResult ="";
	String solCode ="";

	Float impDays;
	
	Date solsubmittedON;
	Float annProdSavings;
	
	
	String benefit = request.getParameter("benefit");
	String benefitType = request.getParameter("benefitType");
	String cmbCustomer = request.getParameter("cmbCustomer");
	String cmbLocation = request.getParameter("cmbLocation");
	String cmbProcessarea = request.getParameter("cmbProcessarea");
	String cmbSolType = request.getParameter("cmbSolType");
	String fromDt = request.getParameter("fromDt");
	String toDt = request.getParameter("toDt");	
	String fname ="";
	String PostedDate;  
	
	SimpleDateFormat dt = new SimpleDateFormat("MM/dd/yyyy"); 
	   
	

	if (cmbCustomer != null)
	{
		qfound = true;
		bCustomer = true;
	}else
	{
		cmbCustomer ="";
	}
	
	
	if (cmbLocation != null)
	{
		qfound = true;
		bLocation = true;
	}else
	{
		cmbLocation ="";
	}
	
	
	
	if (cmbProcessarea != null)
	{
		qfound = true;
		bProcessarea = true;
	}else
	{
		cmbProcessarea ="";
	}
	
	
	if (benefit != null)
	{
		qfound = true;
		bBenefit = true;	
	}else
	{
		benefit ="";
	}
	
	
	if (fromDt != null)
	{
		qfound = true;
		bfromDt = true;
	}else
	{
		fromDt ="";
	}
	
	
	if (toDt != null)
	{
		qfound = true;
		btoDt = true;
	}else
	{
		toDt ="";
	}
	

	Objectify ofy = ObjectifyService.begin();
	Query<SolutionSubmission> brs = ofy.query(SolutionSubmission.class).filter("Status", "Shared");

	if (bCustomer)
	{
		brs.filter("Customer", cmbCustomer);	
	}
	if (bLocation)
	{
		brs.filter("Location", cmbLocation);		
	}
	if (bBenefit)
	{

		//brs.filter("achievedTypeDesc", benefit); //EDITED BY SRVAN ON SEPT 19
		
		if ( benefit.equalsIgnoreCase("Hard Savings") ){
			brs.filter("hasHardSavings",true);
		}else if ( benefit.equalsIgnoreCase("Cost Avoidance") ){
			brs.filter("hasCostAvoidance",true);
		}else if ( benefit.equalsIgnoreCase("Opportunity Costs") ){
			brs.filter("hasOppurtunityCost",true);
		}
		//ADDED Benefit filter for Financial Benefit by Kulprapas on SEP 27,2012
		else {
			brs.filter("achievedTypeDesc",benefit);
		}
		

	}
	if (bProcessarea)
	{
		brs.filter("processArea", cmbProcessarea.replace(" and ", "&"));	
	}
	
	if (bfromDt)
	{
		Date fdate = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss", Locale.ENGLISH).parse(fromDt + " 00:00:01");
		brs.filter("submittedON >=", fdate);		
	}
	if (btoDt)
	{
		Date tdate = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss", Locale.ENGLISH).parse(toDt + " 23:59:59");
		brs.filter("submittedON <=", tdate);		
	}
	
	//Control div to disply depend on the Benefit Type.  - Added By Kulprapas Sep 20,2012
		String div_ach_qa = "none";
		String div_ach_others = "none";
		String div_fin = "none";
		if (benefitType.equals("Financial") ){
			div_fin = "inline";
		}
		else{
			if (benefit.equals("Quality")){
				div_ach_qa = "inline";			
			}
			else{
				div_ach_others = "inline";	
			}
		}
%>
   
<style type="text/css" title="currentStyle">
			@import "../../media/dataTables/css/demo_page.css";
			@import "../../media/dataTables/css/demo_table_jui.css";
			@import "../../media/themes/smoothness/jquery-ui-1.7.2.custom.css";
		</style>
		<script type="text/javascript" language="javascript" src="../../media/dataTables/js/jquery.js"></script>
		<script type="text/javascript" language="javascript" src="../../media/dataTables/js/jquery.dataTables.js"></script>


<script type="text/javascript">
        
	
        $(document).ready(function () {
            $("#ByFinancial").dataTable({
                "sPaginationType": "full_numbers",
                "bJQueryUI": true
            });                          
            
        });
        
        $(document).ready(function () {
            $("#ByQualityRTY").dataTable({
                "sPaginationType": "full_numbers",
                "bJQueryUI": true
            });                          
            
        });
        
        $(document).ready(function () {
            $("#ByQualityDPU").dataTable({
                "sPaginationType": "full_numbers",
                "bJQueryUI": true
            });                          
            
        });
        
        $(document).ready(function () {
            $("#ByQualityDPPM").dataTable({
                "sPaginationType": "full_numbers",
                "bJQueryUI": true
            });                          
            
        });
        
        $(document).ready(function () {
            $("#ByAchievedOthers").dataTable({
                "sPaginationType": "full_numbers",
                "bJQueryUI": true
            });                          
            
        });
        
        </script>

<!-- content -->
<!--<a id="mainContent" name="mainContent"/>-->
<div id="lotusContent">
<div class="lotusLayout lotusHeader">
<!--<h1>Savvy Solutions</h1>
<div class="lotusDetails">The Global Operations Excellence collection of Savvy Solutions resulting in cost savings for the company</div>-->
</div>
<!-- View selector -->
<div class="lotusActionBar lotusBtnContainer">
<!-- Buttons -->
<!--<b>Savvy Solutions for Srinivas Vanamala:</b> -->
<!--<span class="lotusBtn lotusBtnAction lotusLeft">
<a href="/blogs/roller-ui/myblogs/newentry">New Entry</a>
</span>-->
</div>

<div id="lotusContent">
<!--<h1>Savvy Solutions</h1>
<div class="lotusDetails">The Global Operations Excellence collection of Savvy Solutions resulting in cost savings for the company</div>-->
<table >
<tr>
<td colspan="3"><b>Filter By : <%=fname %></b></td>
</tr>



<tr>
<td> Customer : </td><td>
<input name="%%Surrogate_cmbCustomer" type="hidden" value="1">
<select name="cmbCustomer" id="cmbCustomer" class="text-edit">
<option>--Select Customer--</option>
<% 


for(int i = 0 ; i < Crs.size();i++){ 

		if	(cmbCustomer.equals(Crs.get(i).get("CustName").toString())){ %>	
    		 <option selected ="selected" value="<%= Crs.get(i).get("CustName")%>"><%=Crs.get(i).get("CustName")%></option>     
	   <%}
		  else{%>  
    	  <option><%=Crs.get(i).get("CustName")%></option>      
<%} 
	}%>
</select>



 </td><td></td>
</tr>
<tr>
<td> Location : </td><td>
<input name="%%Surrogate_cmbLocation" type="hidden" value="1">
<select name="cmbLocation" id="cmbLocation" class="text-edit">
<option>--Select Location--</option>
<% for(int i = 0 ; i < Lrs.size() ;i++){ 
     if	(cmbLocation.equals(Lrs.get(i).get("LocationName").toString())){ %>	
    		 <option selected ="selected" value="<%= Lrs.get(i).get("LocationName")%>"><%=Lrs.get(i).get("LocationName")%></option>     
	<%}
      else{%>  
      <option><%=Lrs.get(i).get("LocationName")%></option>      
    <%}
}%>
</select>



 </td><td></td>
</tr>
<tr>
<td> Process : </td><td colspan="2">
<input name="%%Surrogate_cmbProcessarea" type="hidden" value="1">
<select name="cmbProcessarea" id="cmbProcessarea" class="text-edit">
<option>--Select Process Area--
</option>
<% for(int i = 0 ; i < Prs.size() ;i++){ 
     if	(cmbProcessarea.equals(Prs.get(i).get("AreaName").toString())){ %>
      <option selected ="selected" value="<%= Prs.get(i).get("AreaName")%>"><%=Prs.get(i).get("AreaName")%></option> 
      	<%}
      else{%>
      <option><%=Prs.get(i).get("AreaName")%></option>
<%}
     }%>
</select>
 </td>
</tr>
<tr><td></td><td></td><td></td></tr>
<tr>
<tr><td></td><td></td><td></td></tr>
<tr>
<td style="vertical-align: bottom;" > Posted Date : </td><td>From:&nbsp;&nbsp;

<input name="fromDt" value="<%=fromDt%>" id="fromDt" class="text-edit"><A 
                        onmouseover="window.status='Click here to select date from calender';return true;" 
onclick='showCalendar(this, document.forms[0].fromDt, "mm/dd/yyyy","en",1)'
                        onmouseout="window.status='';return true;" href="javascript:;"><img src="/img/bx.gif" width="16" height="15" alt="Select Date" border="0"></a></td>
<td>To:&nbsp;&nbsp;
<input name="toDt" value="<%=toDt %>" id="toDt" class="text-edit"><A 
                        onmouseover="window.status='Click here to select date from calender';return true;" 
onclick='showCalendar(this, document.forms[0].toDt, "mm/dd/yyyy","en",1)'
                        onmouseout="window.status='';return true;" href="javascript:;"><img src="/img/bx.gif" width="16" height="15" alt="Select Date" border="0"></a></td>
</tr>
<tr><td></td><td></td><td></td></tr>
<tr><td><span class="lotusBtn lotusBtnAction lotusLeft">
<a href="javascript:Searchdocs()"><b>Show</b></a>
</span></td>
<td colspan="2"><span class="lotusBtn lotusBtnAction lotusLeft">

<a href="javascript:ClearAll()"><b>Clear</b></a>
</span></td>
</tr>
</table>


<br>
<div id="filters" class="lotusPaging" style="display:none">

</div>

<div id='view' style="display:none" >

</div>
<div id="srchResult" style="display:none">

</div>
<br>
<div class="lotusPaging" style="display:none">
</div>
</div>



<div id="dt_financial" style="display:<%=div_fin %>" >
    <div id="container">
        <div id="demo_jui">         
    
          <h2><b> Savvy Solutions shared by <%= benefit %> :</b></h2>	
	<table cellpadding="0" cellspacing="0" border="0" class="display" id="ByFinancial" >
          <thead>
              <tr>
                        <th>Solution ID</th>
						<th>Title</th>
						<th>Customer</th>	
						<th>Process</th>		
						<th>Benefit Results</th>	
						<th># Days to Implement</th>	
						<th># Posted Date</th>		
											
              </tr>
          </thead>
        
          <tbody>
        	<% 
          	  for (SolutionSubmission f : brs.fetch()) {
        		solID = f.getSolID();
        		solCode = f.getSolCode();
        		solTitle = f.getTitle();
        		solCustomer = f.getCustomer();        	
        		solProcessArea = f.getProcessArea();
        		annProdSavings = f.getAnnProdSavings();
				impDays=  f.getImpDays();
				solsubmittedON = f.getSubmittedON();
				PostedDate = dt.format(solsubmittedON);
	            		
	            
			%>
		  <tr>
		    <td><a href="/modules/default/display-solution.jsp?sol_id=<%=solID%>"><%=solCode%></a></td>
		    <td><%=solTitle%></td>
		    <td><%=solCustomer%></td>
			<td><%=solProcessArea%></td>
			<td>$ <%=annProdSavings%> USD</td>
			<td><%=impDays%></td>
			<td><%=PostedDate%></td>
		   
		  </tr>
			<% 
			} 
			%>
          </tbody>
         
      </table>
 
	  </div>
    </div>
</div>
<div id="dt_Achieved"  >
    <div id="dt_AchievedOthers" style="display:<%=div_ach_others %>" >
        <div id="demo_jui">         
    
          <h2><b> Savvy Solutions shared by <%= benefit %> :</b></h2>	
	<table cellpadding="0" cellspacing="0" border="0" class="display" id="ByAchievedOthers"   >
          <thead>
              <tr>
                        <th>Solution ID</th>
						<th>Title</th>
						<th>Customer</th>	
						<th>Process</th>		
						<th>Benefit Results</th>	
						<th># Days to Implement</th>	
						<th># Posted Date</th>		
											
              </tr>
          </thead>
        
          <tbody>
        	<% 
        	
          	  for (SolutionSubmission f : brs.fetch()) {
        		solID = f.getSolID();
        		solCode = f.getSolCode();
        		solTitle = f.getTitle();
        		solCustomer = f.getCustomer();        	
        		solProcessArea = f.getProcessArea();
        		AchievedValue = f.getAchievedValue();  
        		AchievedUnit = f.getAchievedUnits();  
				impDays= f.getImpDays();
				solsubmittedON = f.getSubmittedON();
				PostedDate = dt.format(solsubmittedON);
	            		
	            if (AchievedValue.equals(""))
	            {
	            	BenefitResult = "N/A";
	            }
	            else
	            {
	            	BenefitResult = AchievedValue + " " + AchievedUnit.replace("In","");
	            }
			%>
		  <tr>
		    <td><a href="/modules/default/display-solution.jsp?sol_id=<%=solID%>"><%=solCode%></a></td>
		    <td><%=solTitle%></td>
		    <td><%=solCustomer%></td>
			<td><%=solProcessArea%></td>
			<td><%=BenefitResult %></td>
			<td><%=impDays%></td>
			<td><%=PostedDate%></td>
		   
		  </tr>
			<% 
			} 
			%>
          </tbody>
         
      </table>
 
	  </div>
    </div>
 
    <div id="dt_AchievedQuality" style="display:<%=div_ach_qa %>">
 
        <div id="quality_rty">   
            <h2><b> Savvy Solutions shared by  <%= benefit %> in %RTY :</b></h2>	
			<table cellpadding="0" cellspacing="0" border="0" class="display" id="ByQualityRTY"   >
        	 <thead>
              <tr>
                        <th>Solution ID</th>
						<th>Title</th>
						<th>Customer</th>	
						<th>Process</th>		
						<th>Benefit Results</th>	
						<th># Days to Implement</th>	
						<th># Posted Date</th>		
											
              </tr>
        	 </thead>
        
          <tbody>
        	<% 
        	
          	 for( SolutionSubmission f :brs.fetch()){          		  
        		solID = f.getSolID();
        		solCode = f.getSolCode();
        		solTitle = f.getTitle();
        		solCustomer = f.getCustomer();        	
        		solProcessArea = f.getProcessArea();        	 
        		AchievedUnit = f.getAchievedUnits();  
        		AchievedValue = f.getAchievedValue();        		
				impDays= f.getImpDays();
				solsubmittedON = f.getSubmittedON();
				PostedDate = dt.format(solsubmittedON);	            		
				BenefitResult = AchievedValue + "  " + AchievedUnit;
				if (AchievedUnit.equals("%RTY")){
			%>
		  <tr>
		    <td><a href="/modules/default/display-solution.jsp?sol_id=<%=solID%>"><%=solCode%></a></td>
		    <td><%=solTitle%></td>
		    <td><%=solCustomer%></td>
			<td><%=solProcessArea%></td>
			<td><%=BenefitResult%></td>
			<td><%=impDays%></td>
			<td><%=PostedDate%></td>
		   
		  </tr>
			<% 
			} 
			}
			%>
          </tbody>
         
      </table>
 
	  </div>
	  <br>
	  <div id="quality_dpu">        
            <h2><b> Savvy Solutions shared by  <%= benefit %> in DPU :</b></h2>	
			<table cellpadding="0" cellspacing="0" border="0" class="display" id="ByQualityDPU"   >
        	 <thead>
              <tr>
                        <th>Solution ID</th>
						<th>Title</th>
						<th>Customer</th>	
						<th>Process</th>		
						<th>Benefit Results</th>	
						<th># Days to Implement</th>	
						<th># Posted Date</th>		
											
              </tr>
        	 </thead>
        
          <tbody>
        	<% 
        
          	  for (SolutionSubmission f :brs.fetch()) {
        		solID = f.getSolID();
        		solCode = f.getSolCode();
        		solTitle = f.getTitle();
        		solCustomer = f.getCustomer();        	
        		solProcessArea = f.getProcessArea();        	 
        		AchievedUnit = f.getAchievedUnits();  
        		AchievedValue = f.getAchievedValue();        		
				impDays= f.getImpDays();
				solsubmittedON = f.getSubmittedON();
				PostedDate = dt.format(solsubmittedON);	            		
				BenefitResult = AchievedValue + "  " + AchievedUnit;
				if (AchievedUnit.equals("DPU")){
			%>
		  <tr>
		    <td><a href="/modules/default/display-solution.jsp?sol_id=<%=solID%>"><%=solCode%></a></td>
		    <td><%=solTitle%></td>
		    <td><%=solCustomer%></td>
			<td><%=solProcessArea%></td>
			<td><%=BenefitResult%></td>
			<td><%=impDays%></td>
			<td><%=PostedDate%></td>
		   
		  </tr>
			<% 
			}
				}
			%>
          </tbody>
         
      </table>
 
	  </div>
	  	  <br>
	    <div id="quality_dppm">        
            <h2><b> Savvy Solutions shared by  <%= benefit %> in DPPM :</b></h2>	
			<table cellpadding="0" cellspacing="0" border="0" class="display" id="ByQualityDPPM"   >
        	 <thead>
              <tr>
                        <th>Solution ID</th>
						<th>Title</th>
						<th>Customer</th>	
						<th>Process</th>		
						<th>Benefit Results</th>	
						<th># Days to Implement</th>	
						<th># Posted Date</th>		
											
              </tr>
        	 </thead>
        
          <tbody>
        	<% 
       
          	  for (SolutionSubmission f :brs.fetch()) {
        		solID = f.getSolID();
        		solCode = f.getSolCode();
        		solTitle = f.getTitle();
        		solCustomer = f.getCustomer();        	
        		solProcessArea = f.getProcessArea();        	 
        		AchievedUnit = f.getAchievedUnits();  
        		AchievedValue = f.getAchievedValue();        		
				impDays= f.getImpDays();
				solsubmittedON = f.getSubmittedON();
				PostedDate = dt.format(solsubmittedON);	            		
				BenefitResult = AchievedValue + "  " + AchievedUnit;
				if (AchievedUnit.equals("DPPM")){
			%>
		  <tr>
		    <td><a href="/modules/default/display-solution.jsp?sol_id=<%=solID%>"><%=solCode%></a></td>
		    <td><%=solTitle%></td>
		    <td><%=solCustomer%></td>
			<td><%=solProcessArea%></td>
			<td><%=BenefitResult%></td>
			<td><%=impDays%></td>
			<td><%=PostedDate%></td>
		   
		  </tr>
			<% 
			} 
          	  }
			%>
          </tbody>
         
      </table>
 
	  </div>
	  
	  
    </div>
    
</div>


<!--End of Lotus Content-->
</div>
<!--End of Lotus Content-->

<!--End of Lotus Main-->

<!-- Footer gets moved to within Frame div in weblog.vm so closing tags need to go in weblog.vm - MTodd November 1 2007 </body> </html> -->

<input name="$$HTMLDocType" type="hidden" value="&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;">
<input name="SaveOptions" type="hidden" value="0">
<input name="HTTP_Cookie" type="hidden" value="mailpref=; webchat=1; redirectto=/global/collaboration/SavvySol.nsf/frmHome%3Fopenform; __utma=92377752.1171159035.1345172801.1345172801.1345172801.1; __utmz=92377752.1345172801.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); DomAuthSessId=FB16A96A523B895D2AD9FAA9C64DD351">
<input name="Query_String_Decoded" type="hidden" value="openform&amp;2012">
<input name="Query_String" type="hidden" value="openform&amp;2012">
<input name="dbName" type="hidden" value="">
<input name="benefit" type="hidden" value="<%=benefit%>">

<input name="start" type="hidden" value="1">
<input name="count" type="hidden" value="10">

<input name="benefitType" type="hidden" value="<%=benefitType%>">

<input name="Position" type="hidden" value="">
<input name="curUsername" type="hidden" value="CN=Srinivas Vanamala/OU=SG/OU=Asia/O=Celestica">
<input name="QuickSearch" type="hidden" value="0">
<input name="UserProfileInfo" type="hidden" value="189535317AC64EE385257665005FAC75~4628EE2C7B1ABC70862576880077E8BF~535C09333ABF01B485257654006B0E8D^DTV Process Re-layout~Reduce cosmetic and functional problems at PALM  final quality inspection~Reverse logistics capacity optimization model ^1~0~0^1~0~0">
<input name="txtProfileUNID" type="hidden" value=""></form>
</body>
        
</html>
	
       